package main

import (
	"encoding/json"
	"fmt"
)

type UserInfo struct{
	Name string `json:"name"`
	Pwd int `json:"pwd"`
	Detail  UserDetail `json:"detail"`
}

type UserDetail struct{
	Age int `json:"age"`
	Sex int `json:"sex"`
}


// json 解析
// 结构体 -> json -> map[string]interace{}
func main(){
	userInfo := UserInfo{
		Name:"jmz",
		Pwd:12,
		Detail:UserDetail{12,1},
	}

	info ,_ := json.Marshal(userInfo)

	mapInfo := make(map[string]interface{})

	json.Unmarshal(info,&mapInfo)

	fmt.Println(mapInfo["detail"].(map[string]interface{})["age"])
}
